<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<jsp:include page = "../metadatos.jsp" flush = "True" />
<html>
    <head>
        <title>CATALOGO DE PRODUCTOS</title>
    </head>
    <body>
        <div class="wrapper">
            <header class="header">
                <img src="./resources/Logo.PNG" />
            </header>
            <jsp:include page = "../menuNavegacion.jsp" flush = "True" />
            <main class="content">
                <form class="formee">
                <fieldset>
                    <legend>Calendario</legend>
                    <center>
                        <table width="1000" height="395" border="0">
                            <c:set var="n"  value="${0}"/>
                            <tr>
                                <c:forEach items="${principalCalendario.meses}" var="mes">
                                    <td><div align="center">
                                            <!-- INICIO TABLA INTERNA DE CADA MES -->
                                            <table width="200" height="171" border="1">
                                                <tr>
                                                    <td colspan="7"><div align="center"><c:out value="${mes.nombreMes}"/></div>
                                                        <div align="center"></div>
                                                        <div align="center"></div>
                                                        <div align="center"></div>
                                                        <div align="center"></div>
                                                        <div align="center"></div>
                                                        <div align="center"></div></td>
                                                </tr>
                                                <tr>
                                                    <td width="28"><div align="center">D</div></td>
                                                    <td width="28"><div align="center">L</div></td>
                                                    <td width="28"><div align="center">M</div></td>
                                                    <td width="28"><div align="center">M</div></td>
                                                    <td width="28"><div align="center">J</div></td>
                                                    <td width="28"><div align="center">V</div></td>
                                                    <td width="28"><div align="center">S</div></td>
                                                </tr>
                                                <c:set var="nDia" value="${0}"/>
                                                <c:if test="${mes.diaInicio==1}">  
                                                    <c:set var="nDia" value="${0}"/>
                                                </c:if>
                                                <c:if test="${mes.diaInicio==2}">
                                                    <c:set var="nDia" value="${1}"/>
                                                    <td bgColor=#F6F9ED></td>
                                                </c:if>
                                                <c:if test="${mes.diaInicio==3}">
                                                    <c:set var="nDia" value="${2}"/>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                </c:if>
                                                <c:if test="${mes.diaInicio==4}">
                                                    <c:set var="nDia" value="${3}"/>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                </c:if>
                                                <c:if test="${mes.diaInicio==5}">
                                                    <c:set var="nDia" value="${4}"/>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                </c:if>
                                                <c:if test="${mes.diaInicio==6}">
                                                    <c:set var="nDia" value="${5}"/>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                </c:if>
                                                <c:if test="${mes.diaInicio==7}">
                                                    <c:set var="nDia" value="${6}"/>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                    <td bgColor=#F6F9ED></td>
                                                </c:if>
                                                <c:forEach items="${mes.dias}" var="dia">
                                                    <c:if test="${nDia >= 7}">
                                                        <c:set var="nDia" value="${0}"/>
                                                    </tr><tr>
                                                </c:if> 
                                                <c:set var="nDia" value="${nDia+1}"/>
                                                <td  onclick="popup('Calendario?action=eventsDay&date=<c:out value="${dia.fechaDia}"/>', 800, 500);" onMouseOver="this.bgColor = '#81BEF7'" onMouseOut="this.bgColor = '#FFFFFF'" bgColor=#FFFFFF><div align="center"><c:out value="${dia.numeroDia}"/></div></td>
                                                </c:forEach>  
                                    </table>
                                </div></td>
                                <c:set var="n" value="${n+1}"/>
                                <c:if test="${n==4}">
                                    <c:set var="n" value="${0}"/>
                            </tr><tr>
                            </c:if>
                        </c:forEach>
                </table>
            </center>
        </fieldset>
                </form>
    </main>
</div>
</body>
</html>
<jsp:include page = "../pie.jsp" flush = "True" />